#include "arithmeticExpression"

ast_st *make_ast(const char *expression){//expressio can be 1+2-3*4/5
	ast_st *new = (ast_st *)malloc (sizeof (ast_st));
	
	char *point = expression;
	if (strlen(expression)<=2){
		printf ("erreur bar expression-> too few caracters\n");
		return -1;	
	}
	char ch = * point;
	if (ch =='('){//new expression -> new ast 
		char *match = point++;
		ch= *point++;
		int i=0;//nbre of characters after le parenthese 
		while (ch != ')'){ch= *point++;	i++;}
		if (i<3){ 
			printf ("erreur bar expression in the parentese-> too few caracters\n");
			return -1;
		}
		if (i==3){// perfect a final expression
			ast_st *n = (ast_st *)malloc (sizeof (ast_st));
			
		}
	}	 

}

int evaluate (ast_st *expression){

	if (expression->kind == "Integer"){
		return expression.num;
	}else if (expression->kind == "Double"){
		return expression.flo;	
	}else if (expression->kind == "Plus"){
		return evaluate ((expression->left) + evaluate(expression->rigth));
	}else if (expression->kind == "Minus"){
		return evaluate ((expression->left) - evaluate(expression->rigth));
	}else if (expression->kind == "Mult"){
		return evaluate ((expression->left) * evaluate(expression->rigth));
	}else if (expression->kind == "Div"){
		return evaluate ((expression->left) \ evaluate(expression->rigth));
	}else {printf ("bar expression, can't evaluate this expression "); return -1;}

}
